/**
 * EMailRegister.java
 * 2010-1-14
 */
package com.dlplay.flightinfo.data;

import java.util.logging.Logger;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.dlplay.flightinfo.client.Notification;
import com.dlplay.flightinfo.core.FlightSystem;
import com.google.appengine.api.datastore.Key;

/**
 * @author zhao yu
 *
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class EMailRegister extends FlightRegInfo{
	private static final Logger log = Logger.getLogger(EMailRegister.class.getName());
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	@Persistent
	private String user;
	@Persistent
	private AirlineCode airline;
	@Persistent
	private int number;
	@Persistent
	private String email;
	
	/**
	 * 
	 */
	protected EMailRegister() {

	}
	
	/**
	 * @param user
	 * @param flightNum
	 * @param email
	 */
	public EMailRegister(String user, AirlineCode airline, int number, String email) {
		super();
		this.user = user;
		this.airline = airline;
		this.number = number;
		this.email = email;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}


	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	
	
	
	/**
	 * @return the user
	 */
	public String getUser() {
		return user;
	}

	/**
	 * @param user the user to set
	 */
	public void setUser(String user) {
		this.user = user;
	}


	/**
	 * @return the airline
	 */
	public AirlineCode getAirline() {
		return airline;
	}

	/**
	 * @param airline the airline to set
	 */
	public void setAirline(AirlineCode airline) {
		this.airline = airline;
	}

	/**
	 * @return the number
	 */
	public int getNumber() {
		return number;
	}

	/**
	 * @param number the number to set
	 */
	public void setNumber(int number) {
		this.number = number;
	}

	/* (non-Javadoc)
	 * @see com.dlplay.flightinfo.data.FlightRegisterInfo#notify(com.dlplay.flightinfo.data.Flight, com.dlplay.flightinfo.data.Flight)
	 */
	@Override
	public void notify(RealTimeFlightInfo oldFlight, RealTimeFlightInfo newFlight) {
		log.info("notify:"+this+" oldFlight: "+oldFlight+"newFlight"+newFlight);
//		Notification notification = FlightSystem.getNotificationManager().getEMailNotification(getUser(),email,oldFlight, newFlight);
//		notification.doNotification();
	}



	@Override
	public void welcome(RealTimeFlightInfo info) {
		// TODO todo_5, send a welcome to register
		log.info("welcome to "+getUser());
		
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "EMailRegister [airline=" + airline + ", email=" + email
				+ ", key=" + key + ", number=" + number + ", user=" + user
				+ "]";
	}



}
